package com.rongc.client.core;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;


public abstract class QuickApplication extends Application {
    private static QuickApplication instance;
    private BroadcastReceiver appScopeReceiver;
    public static QuickApplication getInstance() {
        checkInstance();
        return instance;
    }

    private static void checkInstance() {
        if (instance == null)
            throw new IllegalStateException("Application not created yet!");
    }


    protected void initBroadcastFilter(IntentFilter intentFilter) {
        intentFilter.addAction("start.update.client");
    }


    @Override
    public void onCreate() {
        super.onCreate();
        appScopeReceiver = new ApplicationBroadcastReceiver(this);
        IntentFilter intentFilter = new IntentFilter();
        initBroadcastFilter(intentFilter);
        //LocalBroadcastManager.getInstance(this).registerReceiver(appScopeReceiver, intentFilter);
        instance = this;
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        //LocalBroadcastManager.getInstance(this).unregisterReceiver(appScopeReceiver);
    }

    class ApplicationBroadcastReceiver extends BroadcastReceiver {

        public ApplicationBroadcastReceiver(QuickApplication app) {

        }

        @Override
        public void onReceive(Context context, Intent intent) {

        }

    }

}
